package com.ldp.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

/**
 * @author 北巷_东坡
 * @date 2022/10/27 8:09
 * @computer 10741
 */
//@Service
@Component
public class LocalItemService implements LocalTtemServiceImpl {
    @Autowired
    private RestTemplate restTemplate;
    @HystrixCommand(fallbackMethod = "hiError")
    public String hi(String id){
        return restTemplate.getForObject("http://localhost:SpringHystrixProvider/hi?id="+id,String.class);
    }
    public String hiError(String id) {
        return  String.format("Hi，your message is : %s but request bad.",id);
    }

    //    @Override
//    public String hi(String id) {
//        return String.format("Hi，your message is : %s but request bad.",id);
//    }
//}
}
